const promise = new Promise((resolve, reject) => {
  // 这里用于 "兑现" 承诺
  // resolve(100);    // 承诺达成

  reject(new Error("promise rejected")); // 承诺失败
});

promise.then(
  function (val) {
    console.log("resolved", val);
  },
  (error) => {
    console.log("rejected", error);
  }
);
console.log("end");
